<html>

<head>
<title>get post 测试</title>
<style>

    input{
      width:600px;
    }
</style>
</head>

<body>



<h1> get post 测试 </h1>

url <br>
<input type="text" id="url"  value="http://127.0.0.1:8080/test" > 

<form name="form1" method='post' action='' target='blank'>

  <table>

    <tr>
        <td>method</td>
        <td>

           <select id='methodSel'>
               <option>post</option>
               <option>get</option>
           </select>

       </td>
    </tr>

    <tr>
        <td>q</td>
        <td><input type="text" name="q"></td>
    </tr>

    <tr>
        <td>s</td>
        <td><input type="text" name="s"></td>
    </tr>

    <tr>
        <td></td>
        <td>
          <input type="button" name="form1Submit" value='submit' onclick='do_submit()'>
        </td>
    </tr>


  </table>

<form>

<script>

   function do_submit(){
     var url = document.getElementById('url').value;
     if(!url){
        url = "http://127.0.0.1:8080/test";
        form1.url.value=url;
     }
     form1.action=url;
     var methodSelObj = document.getElementById("methodSel");
     var index=methodSelObj.selectedIndex;

     var methodValue = methodSelObj.options[index].value;

     var s = "";
     s = s + "method="+methodValue+"\n";
     s = s+"url="+url+"\n";

     if(methodValue=='get'){
       form1.method=methodValue;
     }else{
       form1.method='post';
     }

     s=s+"form1.method="+form1.method;


     alert(s);

     form1.submit();

   }

</script>

</body>
</html>
